package com.breeze.webview;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.breeze.webview.databinding.ActivityWebViewBinding;
import com.breeze.webview.utils.Constants;

public class WebViewActivity extends AppCompatActivity {
    private ActivityWebViewBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_web_view);
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        Fragment fragment = WebViewFragment.newInstance(getIntent().getStringExtra(Constants.URL), true);
        transaction.replace(R.id.web_view_fragment, fragment).commit();
        boolean showActionBar = getIntent().getBooleanExtra(Constants.SHOW_ACTION_BAR, true);
        if (showActionBar) {
            getSupportActionBar().setTitle(getIntent().getStringExtra(Constants.TITLE));
        } else {
            getSupportActionBar().hide();
        }
    }
}